/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: asus
 * Date: 2025-01-09
 * Time: 17:52
 */
public class IsPalindrome {
    public boolean isPalindrome(String s) {
        int left = 0, right = s.length()-1;
        while (left < right) {
            char cl = s.charAt(left);
            char cr = s.charAt(right);
            if (!Character.isLetterOrDigit(cl)) {
                left++;
                continue;
            }
            if (!Character.isLetterOrDigit(cr)) {
                right--;
                continue;
            }
            cl = Character.toLowerCase(cl);
            cr = Character.toLowerCase(cr);
            if (cl != cr) {
                return false;
            }
            left++;
            right--;
        }
        return true;
    }
}
